﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<form id="form1">
    <div style="padding-top: 20px; margin-right: 30px;">
        <table class="form">
            <tr>
                <th class="formTitle">上级：</th>
                <td class="formValue">
                    <select id="ParentId" name="ParentId" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                </td>
                <th class="formTitle"><span class="required">*</span>名称：</th>
                <td class="formValue">
                    <input type="hidden" name="OrganizeId" id="OrganizeId" />
                    <input id="Name" name="Name" type="text" class="form-control required" placeholder="请输入名称" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">英文菜单：</th>
                <td class="formValue">
                    <input id="EnName" name="EnName" type="text" class="form-control" placeholder="" />
                </td>
                <th class="formTitle">外部应用：</th>
                <td class="formValue">
                    <input id="AppId" name="AppId" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">连接：</th>
                <td class="formValue">
                    <input id="UrlAddress" name="UrlAddress" type="text" class="form-control" />
                </td>
                <th class="formTitle"><span class="required">*</span>目标：</th>
                <td class="formValue">
                    <select id="Target" name="Target" class="form-control required">
                        <option value="">==请选择==</option>
                        <option value="expand" title="expand">无页面</option>
                        <option value="iframe" title="iframe">框架页</option>
                        <option value="open" title="open">弹出页</option>
                        <option value="blank" title="blank">新窗口</option>
                        <option value="subpage" title="subpage">子页面</option>
                        <option value="toplocation" title="toplocation">当前窗口</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">图标：</th>
                <td class="formValue">
                    <div class="input-group">
                        <input id="Icon" name="Icon" type="text" class="form-control">
                    </div>
                </td>
                <th class="formTitle">排序：</th>
                <td class="formValue">
                    <input id="px" name="px" type="text" class="form-control" placeholder="请输入排序" />
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">选项：</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="zt" name="zt" type="checkbox" checked="checked"><label for="zt">有效</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th class="formTitle" valign="top" style="padding-top: 5px;">
                    介绍：
                </th>
                <td class="formValue" colspan="3">
                    <textarea id="Description" name="Description" class="form-control" style="height: 100px;"></textarea>
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    var keyValue = $.request("keyValue");
    $(function () {
        initControl();
        if (!!keyValue) {
            $.najax({
                url: "/SystemManage/SysModule/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        }
        else {
            $('#zt').click(function () {
                return false;
            });
        }
    });

    function initControl() {
        $("#Target").select2();
        $("#ParentId").bindSelect({
            url: "/SystemManage/SysModule/GetTreeSelectJson",
        });
    }

    function AcceptClick(callBack) {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/SystemManage/SysModule/SubmitForm?keyValue=" + keyValue,
            param: $("#form1").formSerialize(),
            success: function () {
                callBack();
                $.modalClose();
            }
        })
    }
</script>